/* DBconnecttion.java 
* Created on Dec 20, 2012 
* Author:Mr.Viet
* Phone: 01683430426
* Email: phamvanvietcdhd@gmail.com
*/ 
package com.icode.utils; 

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class DBconnecttion {
	private static Connection conn;
	public static Connection getConnection(){
		if(conn == null){
			try {
				//Step1: Dang Ki Driver
				Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
				//Step2: Tao Connection
				conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=mydb","sa","anhbac");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return conn;
		
	}
}
